export default () => {

    // 倒计时，从给定的分钟数开始倒计时
    const h = ref(0)
    const m = ref(0)
    const s = ref(0)
    let timer = null
    const start = (minute) => {

        h.value = Math.floor(minute / 60);
        m.value = minute % 60;
        timer = setInterval(() => {
            if (s.value === 0) {
                if (m.value === 0) {
                    if (h.value === 0) {

                        clearInterval(timer)
                        return
                    }

                    h.value--
                    m.value = 59
                    s.value = 59
                }
                m.value--
                s.value = 59
            } else {
                s.value--
            }
        }, 1000)
    }
    const stop = () => {
        clearInterval(timer)
    }
    return {
        h,
        m,
        s,
        start,
        stop
    }
};